package com.example.myretrofit2.presenter;

import com.example.myretrofit2.User;
import com.example.myretrofit2.httpMesholds.HttpMesholds;
import com.example.myretrofit2.httpResult.HttpResult;

import java.util.List;

import rx.Observable;
import rx.Subscriber;
import rx.functions.Func1;

public class MyPresenter extends HttpMesholds {
    public static void getUser(String id, Subscriber<List<User>> s) {
        Observable<List<User>> observable = userService.getUser(id).map(new ResultFunc1<List<User>>());
        toSub(observable,s);
    }
    public static void InsertUser(User user,Subscriber<Boolean> s){
        Observable<Boolean> observable = userService.insertUser(user).map(new ResultFunc1<Boolean>());
        toSub(observable,s);
    }
     public static  void addUser(User user,Subscriber<List<User>> s){
        Observable observable = userService.addUser(user).map(new ResultFunc1<Boolean>());
        toSub(observable,s);
    }
    public static void isLogin(Subscriber<Boolean> s){
        Observable observable = userService.isLogin().map(new ResultFunc1<Boolean>());
        toSub(observable,s);
    }
    public static void login(User user,Subscriber<User> s){
        Observable observable = userService.login(user).map(new ResultFunc1<User>());
        toSub(observable,s);
    }
    public static void updateUser(String newpass,Subscriber<Boolean> s){
        Observable observable = userService.updateUser(newpass).map(new ResultFunc1<Boolean>());
        toSub(observable,s);
    }

    public static void QueryUser(User user,Subscriber<Boolean> s){
        Observable observable = userService.cx(user).map(new ResultFunc1<Boolean>());
        toSub(observable,s);
    }

}
